<template>
	<view class="recharge">
		<view class="card">
			<view class="top">
				输入金额(元)
			</view>
			<view class="inp">
				<view class="left">
					￥
				</view>
				<view class="right">
					<input type="number" disabled v-model="price">
				</view>
				<view class="btn" @click="recharge">
					充值
				</view>
			</view>
		</view>
		<view class="tip">
			声明：为激活电子钱包，需向电子钱包充值一分钱，以便后续现金红包的正常发放。
		</view>
	</view>
</template>

<script>
	import {
		getPhoneCode,
		getTwoUserList,
		getMoneny,
		idCardOCR,
		rechargeCode,
		rechargePay
	} from '../../common/api/blank.js';
	import {
		_showLoading,
		_showToast
	} from '../../common/js/util.js'
	export default {
		data() {
			return {
				price: 0.01,
				batId: "",
				phone: "",
				orgId: "",
				qy: ""
			}
		},
		onBackPress(options) {
			if (options.from === 'navigateBack') {
				return false
			}
			this.back();
			return true
		},
		onLoad(option) {
			this.orgId = option.orgId
			this.phone = option.phone
			this.batId = option.batId
			this.qy = option.qy
		},
		components: {

		},
		methods: {
			back() {
				var pages = getCurrentPages();
				uni.navigateBack()
			},
			async recharge() {
				if (this.price) {
					try {
						const res = await rechargeCode({
							batId: this.batId,
							amount: this.price,
							orgId: this.orgId
						})
						console.log(res)
						if (res.code === 0) {
							if (res.data.responseStatus === 'S') {
								uni.navigateTo({
									url: `/pageMassage/redPacketSendCode/redPacketSendCode?price=${this.price}&batId=${this.batId}&msgMerTranNo=${res.data.msgMerTranNo}&phone=${this.phone}&orgId=${this.orgId}&qy=${this.qy}`
								})
							}
							if (res.data.responseStatus === 'F') {
								_showToast(res.data.responseMsg)
							}
						} else {
							_showToast(res.msg)
						}

					} catch (err) {
						_showToast(err)
					}
				} else {
					_showToast("充值金额不能为空")
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
		width: 100%;
	}

	page-body {
		height: 100%;
		width: 100%;
	}

	.recharge {
		box-sizing: border-box;
		padding: 70rpx 30rpx 0rpx 30rpx;
		height: 100%;

		.tip {
			padding-top: 40rpx;
			font-size: 30rpx;
			color:red;
		}

		.card {
			width: 690rpx;
			height: 234rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 26rpx 1rpx rgba(0, 0, 0, 0.06);
			border-radius: 6rpx 6rpx 6rpx 6rpx;
			opacity: 1;
			padding-top: 28rpx;
			box-sizing: border-box;

			.top {
				height: 46rpx;
				font-size: 32rpx;
				font-family: Source Han Sans CN-Medium, Source Han Sans CN;
				font-weight: 500;
				color: #40424E;
				line-height: 46rpx;

				margin-left: 32rpx;
				margin-bottom: 26rpx;
			}

			.inp {
				display: flex;
				margin-left: 32rpx;
				border-bottom: 1rpx solid #ccc;

				.btn {
					width: 148rpx;
					height: 72rpx;
					background: #3478F5;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
					opacity: 1;
					font-size: 32rpx;
					font-family: Source Han Sans CN-Light, Source Han Sans CN;
					font-weight: 300;
					color: #FFFFFF;
					line-height: 72rpx;
					text-align: center;
					margin-bottom: 15rpx;
					margin-left: 10rpx;
				}

				.left {
					width: 46rpx;
					height: 66rpx;
					font-size: 46rpx;
					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #40424E;
					line-height: 66rpx;
				}

				.right {
					width: calc(100% - 204rpx);
					height: 66rpx;
					line-height: 66rpx;

					font-family: Source Han Sans CN-Medium, Source Han Sans CN;
					font-weight: 500;
					color: #40424E;

					input {
						width: 100%;
						height: 66rpx;
						font-size: 46rpx;
					}
				}
			}
		}
	}
</style>